package com.cndongtai.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.cndongtai.dao.BaseDao;
import com.cndongtai.dao.inter.TorchnBatteryCollectRecordMapper;
import com.cndongtai.po.TorchnBatteryCollectRecord;

@Repository("torchnBatteryCollectRecordDao")
public class TorchnBatteryCollectRecordDao extends BaseDao implements TorchnBatteryCollectRecordMapper {

	@Override
	public int addTorchnBatteryCollectRecord(TorchnBatteryCollectRecord record) {
		SqlSession sqlSession = getSqlSession();
		try {
			TorchnBatteryCollectRecordMapper operation = sqlSession.getMapper(TorchnBatteryCollectRecordMapper.class);
			return operation.addTorchnBatteryCollectRecord(record);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return 0;
	}

	@Override
	public Double queryBatteryChargeQuantity(String deviceName) {
		SqlSession sqlSession = getSqlSession();
		try {
			TorchnBatteryCollectRecordMapper operation = sqlSession.getMapper(TorchnBatteryCollectRecordMapper.class);
			return operation.queryBatteryChargeQuantity(deviceName);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return new Double(0);
	}

	@Override
	public Double queryBatteryWorkQuantity(String deviceName) {
		SqlSession sqlSession = getSqlSession();
		try {
			TorchnBatteryCollectRecordMapper operation = sqlSession.getMapper(TorchnBatteryCollectRecordMapper.class);
			return operation.queryBatteryWorkQuantity(deviceName);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return new Double(0);
	}

	@Override
	public List<TorchnBatteryCollectRecord> queryBatteryCollectRecord(
			String deviceName) {
		SqlSession sqlSession = getSqlSession();
		try {
			TorchnBatteryCollectRecordMapper operation = sqlSession.getMapper(TorchnBatteryCollectRecordMapper.class);
			return operation.queryBatteryCollectRecord(deviceName);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

	
	
}
